package cn.sundat.web.filter;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter;
/*
 * 自定义的过滤器
 */
public class MyStrutsFilter extends StrutsPrepareAndExecuteFilter {
	
	@Override
	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
			throws IOException, ServletException {
		//强转
		HttpServletRequest request = (HttpServletRequest) req;
		String url = request.getRequestURI();
		System.out.println(url);
		if(url.contains(request.getContextPath()+"/manage/uedit1_4_3/jsp/controller.jsp")) {
			System.out.println("使用自定义过滤器");
			chain.doFilter(req, res);
		}else {
			System.out.println("使用默认的过滤器");
			super.doFilter(req, res, chain);
		}
	}
	
}
